﻿#include "reportInterface.h"

ReportInterface::ReportInterface()
{

}

int ReportInterface::exportReport(){

//    QString path = QFileDialog::getSaveFileName(NULL, "导出报告", "/path/to/default/", "Word(*.docx);;Excel(*.xlsx);;Csv(*.csv)");
    QString path = QFileDialog::getSaveFileName(NULL, "导出报告", "/path/to/default/", "Word(*.docx)");       // 暂时只保存Word类型报告

    ReportManager::I().exportReport(path);

    return 0;
}

QString ReportInterface::getExportPath(){
    return ReportManager::I().getExportPath();
}
bool ReportInterface::getAutoExport(){
    return ReportManager::I().isAutoExport();
}

int ReportInterface::getExportType(){
    return ReportManager::I().getExportType();
}

QString ReportInterface::selectExportPath(){
    return QFileDialog::getExistingDirectory();
}

bool ReportInterface::updateExportInfo(QString path, int type, bool autoExport){
    type = std::max(0, std::min(2, type));
    ReportManager::I().setExportPath(path);
    ReportManager::I().setExportType(ReportManager::ExportType(type));
    ReportManager::I().setAutoExport(autoExport);
    return true;
}

void ReportInterface::updateExperimentInfo(QVariantMap info){
    QMap<QString, QString> mapInfo;
    for(auto iter = info.begin(); iter != info.end(); iter ++){
        mapInfo[iter.key()] = iter.value().value<QString>();
    }
    ReportManager::I().updateExperimentInfo(mapInfo);
}
